package com.med.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Description: 数据传输对象
 * @Param:
 * @return:
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RespondDTO {
    private Integer code;//状态码  1-成功  0-失败
    private String msg;//提示文字
    private Object data;//数据


    private static final Integer SUCCESS_CODE = 1;
    private static final Integer ERROR_CODE = 0;
    private static final Integer ERROR_STATUS = 401;

    /**
     * @Description: 查询使用
     * @Param:
     * @return:
     */
    public static RespondDTO success(Object data) {
        return new RespondDTO(SUCCESS_CODE, "success", data);
    }


    /**
     * @Description: 删除、修改、增加使用
     * @Param:
     * @return:
     */

    public static RespondDTO success() {
        return new RespondDTO(SUCCESS_CODE, "success", null);
    }

    public static RespondDTO error() {
        return new RespondDTO(ERROR_CODE, "error", null);
    }

    public static RespondDTO error(String message) {
        return new RespondDTO(ERROR_CODE, message, null);
    }

    public static RespondDTO fail(String message) {
        return new RespondDTO(ERROR_STATUS, message, null);
    }

    public static RespondDTO error(Integer code, String message) {
        return new RespondDTO(code, message, null);
    }

    // 新增：支持自定义提示消息和数据
    public static RespondDTO success(String message, Object data) {
        return new RespondDTO(SUCCESS_CODE, message, data);
    }


}
